<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="ui" uri="http://com.am.tag2" %>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'userList.jsp' starting page</title>
     <style type="text/css">
    	.linkActive{color:#ff9900;text-decoration:none;font-weight:bold;}
		.linkNoActive{color:#3399ff;}
    </style>
    <script type="text/javascript" src="${path}/js/public/grid.js"></script>
  	<script type="text/javascript">
  	
	  	//0--学生 1-教职工 2-退休 3-离休  4-其他
		var viewArray = ["0","1","2","3","4"];
	  	
		function addCss(id){
    		$.each( viewArray, function(n, i){
    			if(i == id){
    				$("#"+i).find("span").removeClass();
    				$("#"+i).find("span").addClass("linkActive");
    			}else {
    				$("#"+i).find("span").removeClass();
    				$("#"+i).find("span").addClass("linkNoActive");
    			}
    		});
    	}
		
		$().ready(function(){
	    	
    		addCss("0");
    		doChangeView("0");
    	});
		
	  
  		function doSave()
  		{
  			openDailog("view","${path}/jsp/person/personEdit.jsp",680,320,"添加人员",false,true,null,function(dlg){
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		function doEdit()
  		{
  			if(!isSelectOne(mygrid))
  			{
  				alert("请选择一条记录进行修改");
  				return;
  			}
			openDailog("view","${path}/jsp/person/personEdit.jsp",680,320,"修改人员",false,true,mygrid.getSelectedRecords()[0],function(dlg){
  				
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		
  		function doImport()
  		{
  			dlg = new Dialog("viewSheet");
			dlg.Width = 500;
			dlg.Height = 150;
			dlg.Title = "数据导入";
			dlg.URL = "${path}/jsp/person/excelImport.jsp";
			dlg.ShowMessageRow = true;
			dlg.ShowButtonRow = false;
			dlg.addParam("window", window);
			dlg.MessageTitle = "<b>从Excel文件导入数据</b>"; 
			dlg.Message = "<font color='red'>Excel中的列数必须与表的列数一致</font>，并且数据项从第2行开始，第1行为表头。<br>选中文件之后即自动上传、导入";
			dlg.show();
  		}
  		
  		function doCardImport()
  		{
  			dlg = new Dialog("viewSheet");
			dlg.Width = 500;
			dlg.Height = 150;
			dlg.Title = "数据导入";
			dlg.URL = "${path}/jsp/person/cardImport.jsp";
			dlg.ShowMessageRow = true;
			dlg.ShowButtonRow = false;
			dlg.addParam("window", window);
			dlg.MessageTitle = "<b>从Excel文件导入数据</b>"; 
			dlg.Message = "<font color='red'>Excel中的列数必须与表的列数一致</font>，并且数据项从第2行开始，第1行为表头。<br>选中文件之后即自动上传、导入";
			dlg.show();
  		}
  		
  		function doMedicalImport(){
  			dlg = new Dialog("viewSheet");
			dlg.Width = 500;
			dlg.Height = 150;
			dlg.Title = "参保数据导入";
			dlg.URL = "${path}/jsp/person/medicalImport.jsp";
			dlg.ShowMessageRow = true;
			dlg.ShowButtonRow = false;
			dlg.addParam("window", window);
			dlg.MessageTitle = "<b>从Excel文件导入数据</b>"; 
			dlg.Message = "<font color='red'>Excel中的列数必须与表的列数一致</font>，并且数据项从第2行开始，第1行为表头。<br>选中文件之后即自动上传、导入";
			dlg.show();
  		}
  		
  		function doCancelMedicalImport(){
  			dlg = new Dialog("viewSheet");
			dlg.Width = 500;
			dlg.Height = 150;
			dlg.Title = "取消参保数据";
			dlg.URL = "${path}/jsp/person/cancelMedicalImport.jsp";
			dlg.ShowMessageRow = true;
			dlg.ShowButtonRow = false;
			dlg.addParam("window", window);
			dlg.MessageTitle = "<b>从Excel文件导入数据</b>"; 
			dlg.Message = "<font color='red'>Excel中的列数必须与表的列数一致</font>，并且数据项从第2行开始，第1行为表头。<br>选中文件之后即自动上传、导入";
			dlg.show();
  		}
  		
  		function doView()
  		{
  			if(!isSelectOne(mygrid))
  			{
  				alert("请选择一条记录进行查看");
  				return;
  			}
  			
  			var record = mygrid.getSelectedRecords()[0];
  			
			openDailog("view","${path}/jsp/person/viewInfo.jsp?personId=" + record['id'],680,300,"看病信息",false,true,null);
  		}
  		
  		function makeCard()
  		{
  			if(!isSelectOne(mygrid))
  			{
  				alert("请选择一个人员进行制卡");
  				return;
  			}
  			
  			var record = mygrid.getSelectedRecords()[0];
  			
			openDailog("view","${path}/jsp/person/makeCard.jsp",680,330,"制作医疗卡",false,true,record);
  		}
  		
  		function makeCards()
  		{
  			openDailog("view","${path}/jsp/person/makeCards.jsp",1050,570,"批量制作医疗卡",false,true,null,function(dlg){
				dlg.getIFrame().doPrintAll();
			});
  		}
  		
  		function doQuery()
  		{
  			resetGrid(mygrid,"queryForm",{"type":currentView});
  		}
  		
  		var currentView = "0";
  		function doChangeView(flag)
    	{
    		addCss(flag);
    		currentView = flag;
  			resetGrid(mygrid,null,{"type":flag});
    	}
  		
  		function doDisable()
  		{
  			dlg = new Dialog("viewSheet");
			dlg.Width = 500;
			dlg.Height = 120;
			dlg.Title = "学生导出";
			dlg.URL = "${path}/jsp/person/personExport.jsp";
			dlg.ShowMessageRow = true;
			dlg.ShowButtonRow = true;
			dlg.addParam("window", window);
			dlg.MessageTitle = "<b>学生导出</b>";
			dlg.OKEvent = function(){
				dlg.getIFrame().doSave();
			};
			dlg.Message = "<font color='red'>输入学号前缀之后，系统将会按照学号进行筛选</font>，符合的学生类型将会从学生变成其他";
			dlg.show();
  		}
  		
  		function statusRender(value)
  		{
  			if(value == "0"){
  				return "不在册";
  			}else{
  				return "在册";
  			}
  		}
  		
  		function typeRender(value)
  		{
  			if(value == "0"){
  				return "学生";
  			}else if(value == "1"){
  				return "教职工";
  			}else if(value == "2"){
  				return "退休";
  			}else if(value == "3"){
  				return "离休";
  			}else{
  				return "其他";
  			}
  		}
  		
  		
  		function overdueRender(value)
  		{
  			if(value == "1"){
  				return "<img src='${path}/images/6.png' width='15px' height='15px'/>过期";
  			}else{
  				return "<img src='${path}/images/1.png' width='15px' height='15px'/>未过期";
  			}
  		}
  		
  		function doReset()
  		{
  			$("#name").val("");
  			$("#sex").val("");
  			$("#campus").val("");
  			$("#id_card").val("");
  			$("#card_num").val("");
  			$("#class").val("");
  			$("#anamnesis").val("");
  			$("#num").val("");
  		}
  		
  	</script>
  </head>
  <body>
  	<table id="" cellSpacing="0" cellPadding="0" style="width:100%;height:100%;" border="0">
  		<tr>
			<td class="windowTitle">人员管理  &gt; 人员信息管理</td>
		</tr>
  		<tr id="">
			<td style="height:35px;width:100%" class="windowHead">	
				<form id="queryForm">
					<table cellSpacing="0" cellPadding="0" width="100%" height="100%" border="0" >
						<tr>
							<td width="800" height="20" valign="middle">	
								<img alt="view" src="${path}/images/menu/view.png" height="18px" width="20px" align="top"></img>
								<font style="font-weight:bold;">&nbsp;视图：</font>&nbsp;&nbsp;
								<a href="javascript:doChangeView('0')" id="0"><span>学生</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('1')" id="1"><span>教职工</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('2')" id="2"><span>退休</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('3')" id="3"><span>离休</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('4')" id="4"><span>其他</span></a>&nbsp;&nbsp;
							</td>
						</tr>
						<tr>
							<td>
								<table cellpadding="0" cellspacing="0" style="border: 0">
									<tr height="25px">
										<td width="60px" align="right">姓名：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_name" id="name" type="text" class="textbox" style="width:145px;" /></td>
										<td width="80px" align="right">性别：</td>
										<td width="145px" align="left">
											<select name="search_EQ_sex" id="sex" style="width:145px;margin-left: 3px">
												<option value ="">-- 请选择 --</option>
									  			<option value ="男">男</option>
									  			<option value ="女">女</option>
											</select>
										</td>
										<td width="80px" align="right">所在校区：</td>
										<td width="145px" align="left">
											<select name="search_EQ_campus" id="campus" style="width:145px;margin-left: 3px">
												<option value="">--请选择--</option>
												<option value="校本部">校本部</option>
												<option value="白云校区">白云校区</option>
												<option value="北校区">北校区</option>
												<option value="西校区">西校区</option>
											</select>
										</td>
										<td width="100px" align="right">学号/工资卡号：</td>
										<td width="145px" align="left">
											<input name="search_CONTAIN_num" id="num" type="text" class="textbox" style="width:145px;" />
										</td>
										<td width="60px" align="right"><ui:Button type="query" onclick="doQuery()">查询</ui:Button></td>
									</tr>
									<tr height="25px">
										<td width="60px" align="right">证件号：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_id_card" id="id_card" type="text" class="textbox" style="width:145px;" /></td>
										<td width="80px" align="right">医疗卡号：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_card_num" id="card_num" type="text" class="textbox" style="width:145px;" /></td>
										<td width="80px" align="right">班级/部门：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_class" id="class" type="text" class="textbox" style="width:145px;" /></td>
										<td width="100px" align="right">既往病史：</td>
										<td width="145px" align="left">
											<input name="search_CONTAIN_anamnesis" id="anamnesis" type="text" class="textbox" style="width:145px;" />
										</td>
										<td width="60px" align="right"><ui:Button onclick="doReset()"><img src="${path}/images/menu/reset.png" />重置</ui:Button></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td>
								<ui:Permission value="person_add">
									<ui:Button type="save" onclick="doSave()">新增</ui:Button>
								</ui:Permission>
								<ui:Permission value="person_modify">
									<ui:Button type="edit" onclick="doEdit()">修改</ui:Button>
								</ui:Permission>
								<ui:Permission value="person_notregister">
									<ui:Button type="delete" onclick="doDisable()">导出</ui:Button>
								</ui:Permission>
								<ui:Permission value="import_person">
									<ui:Button type="export" onclick="doImport()">导入人员数据</ui:Button>
								</ui:Permission>
								<ui:Permission value="import_card">
									<ui:Button type="export" onclick="doCardImport()">导入医疗卡数据</ui:Button>
								</ui:Permission>
								<ui:Permission value="import_medical">
									<ui:Button type="export" onclick="doMedicalImport()">导入参保数据</ui:Button>
								</ui:Permission>
								<ui:Permission value="import_cancelMedical">
									<ui:Button type="export" onclick="doCancelMedicalImport()">取消参保数据</ui:Button>
								</ui:Permission>
								<ui:Button onclick="doView()"><img src="${path}/images/info.png">看病信息</ui:Button>
								<ui:Button onclick="makeCard()"><img style="width:20px;hight:20px" src="${path}/images/security_card.png">制卡</ui:Button>
								<ui:Button onclick="makeCards()"><img style="width:20px;hight:20px" src="${path}/images/security_card.png">批量制卡</ui:Button>
							</td>
						</tr>
						<tr>
						</tr>
					</table>
				</form>
				<br/>
				<a style="text-decoration: none;"></a>
			</td>
		</tr>
		<tr id="">
			<td style="width:100%;height:100%;overflow:hidden"  class="windowBody">
				<div id="mess_box" style="width:100%;height:100%;overflow:hidden">
					<ui:Grid id="mygrid" css="width:100%;height:100%"
				    		 onCellClicked="selectedSingleRow2"
				    		 rowPrePage="15" 
				    		 autoLoad="false"
				    		 dataProvider="com.system.provider.PersonListProvider:getData" >
				    	<ui:GridField name="id" header="ID" isChecked="true" align="center"/>
				    	<ui:GridField name="name" header="姓名" align="center" width="15%"/>
				    	<ui:GridField name="sex" header="性别"  align="center" width="8%"/>
				    	<ui:GridField name="id_card" header="证件号" align="center" width="15%"/>
				    	<ui:GridField name="card_num" header="医疗卡号" align="center" width="15%"/>
				    	<ui:GridField name="is_overdue" header="医疗卡是否过期" align="center" width="10%" render="overdueRender"/>
				    	<ui:GridField name="campus" header="所在校区" align="center" width="10%"/>
				    	<ui:GridField name="anamnesis" header="既往病史" align="left" width="15%"/>
				    	<ui:GridField name="birthday" header="出生日期" align="center" width="10%"/>
				    	<ui:GridField name="num" header="学号/工资卡号" align="center" width="14%"/>
				    	<ui:GridField name="type" header="类型" render="typeRender" align="center" width="8%"/>
				    	<ui:GridField name="telephone" header="联系电话" align="center" width="15%"/>
				    	<ui:GridField name="class" header="班级/部门" align="center" width="15%"/>
				    	<ui:GridField name="address" header="地址" align="center" width="15%"/>
				    	<ui:GridField name="is_public_medicine" header="是否省公医" align="center" width="8%"/>
				    	<ui:GridField name="status" header="状态" render="statusRender" align="center" width="8%"/>
			    	</ui:Grid>
		    	</div>
		    </td>
		</tr>
  	</table>
  	<script type="text/javascript">
		$().ready(function(){
			disableSelectAll(mygrid);
		});
	</script>
  </body>
</html>
